/*
============================================================================
 Name        : IMEIReader.cpp
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : CIMEIReader implementation
============================================================================
*/

#include "IMEIReader.h"

CIMEIReader* CIMEIReader::NewL(MIMEIObserver* aObserver)
{
	CIMEIReader* self = NewLC(aObserver);
	CleanupStack::Pop(self);
	return self;
}

CIMEIReader* CIMEIReader::NewLC(MIMEIObserver* aObserver)
{
	CIMEIReader* self = new (ELeave) CIMEIReader(aObserver);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
}


CIMEIReader::CIMEIReader(MIMEIObserver* aObserver)
:CActive(EPriorityStandard), iObserver(aObserver), iIdV1Pkg(iIdV1)
{
}

CIMEIReader::~CIMEIReader()
{
	Cancel();
	delete iTelephony;	
}

void CIMEIReader::ConstructL(void)
{	
	CActiveScheduler::Add(this);

	iTelephony = CTelephony::NewL();
	iTelephony->GetPhoneId(iStatus,iIdV1Pkg);
	SetActive();	
}

void CIMEIReader::DoCancel()
{
	iTelephony->CancelAsync(CTelephony::EGetPhoneIdCancel);
}

void CIMEIReader::RunL()
{
	iObserver->GotIMEIL(iIdV1.iSerialNumber,iStatus.Int());
}
